package ModelLayer;
import java.util.ArrayList;

/**
 * Write a description of class OrderContainer here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class OrderContainer
{
    private ArrayList<Order> orders;
    private static OrderContainer instance;

    /**
     * Constructor for object of class OrderContainer.
     */
    private OrderContainer()
    {
        orders = new ArrayList<Order>();
    }

    /**
     * Singleton, so only one instance of OrderContainer can be made.
     */
    public static OrderContainer getInstance()
    {
        if(instance == null)
        {
            instance = new OrderContainer();
        }
        return instance;
    }

    /**
     * Adds an order to the arraylist orders and assigns an idnumber to the order.
     * @param order, the order to be added and given an id.
     */    
    public void addOrder(Order order)
    {
        orders.add(order);
        int id = 10000;
        for(Order order2 : orders)
            if(order2.getOrderId() > id)
            {
                id = order2.getOrderId();
        }
        id++;
        order.setOrderId(id);
    }


}
